
package com.hx.portal.controller.order;


import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.order.pojo.Drug;
import com.hx.order.service.DrugService;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/drug")
@Api(description = "药物相关接口文档")
public class DrugController {

    @Reference
    private DrugService drugService;

    @GetMapping("/findAll")
    public List<Drug> findAll(){
        return drugService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Drug> findPage(int page, int size){
        return drugService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Drug> findList(@RequestBody Map<String,Object> searchMap){
        return drugService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Drug> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  drugService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Drug findById(Long id){
        return drugService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Drug drug){
        drugService.add(drug);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Drug drug){
        drugService.update(drug);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        drugService.delete(id);
        return new Result();
    }

}

